import $ from 'jquery'

export default {
  install (Vue, options) {
    Vue.prototype.setDistanceJud = function () {
      function Distance_jud () {
        var W = $('body').width()
        var H = $(window).height()
        var Hbodyl = $('.bodyl').height()
        var Wl = $('.bodyl').width()
        var H1 = H - 168
        var W1 = W - Wl - 2
        $('.bodyr').width(W1)
        var Topbodyr = $('.bodyr').offset().top
        if (Topbodyr > 200) {
          for (var i = 0; i < 300; i++) {
            W1 = W - i - 2
            $('.bodyr').width(W1)
            if ($('.bodyr').offset().top < 200) {
              break
            }
          }
        }
        if (Hbodyl < H1) {
          $('.bodyer').height(H1)
        } else {
          $('.bodyer').height(Hbodyl)
        }
      }

      Distance_jud()

      $(window).on('resize', function () {
        Distance_jud()
      })

      $('.new_arrow').click(function () {
        var Timg = $(this).find('img')[0]
        if ($(Timg).attr('src') === '/static/pc/img/24.png') {
          $(Timg).attr('src', '/static/pc/img/25.png')
          $('.bodyl').width(20)
          Distance_jud()
        }
        else {
          $(Timg).attr('src', '/static/pc/img/24.png')
          $('.bodyl').width(238)
          console.log($('body').height())
          Distance_jud()
        }
      })

      $('.bodyl_tit').click(function () {
        $('.bodyl_con_chil').slideUp('400')
        $(this).parents('li').find('.bodyl_con').slideToggle('400')
        var img_s = $(this).find('.bodyl_titr')
        if (img_s.attr('src') === '/static/pc/img/16.png') {
          img_s.attr('src', '/static/pc/img/17.png')
        } else {
          img_s.attr('src', '/static/pc/img/16.png')
        }
        $('.bodyl_titr1').attr('src', '/static/pc/img/17.png')
        Distance_jud()
      })
    }
  }
}
